package com.etone.smartAudit.controller;

import com.etone.smartAudit.service.OfficeService;
import com.etone.smartAudit.vo.PagerVO;
import com.etone.smartAudit.vo.office.OfficeBaseVO;
import com.etone.smartAudit.vo.office.OfficeListVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

/**
 * @author: 蒋学伟
 * @create: 2020-07-21 08:39:15
 * @Description OfficeController
 */
@AllArgsConstructor
@RestController
@Api(tags = "事务所", value = "OfficeController")
public class OfficeController {

    private OfficeService officeService;

    @ApiOperation(value = "事务所列表《完》")
    @GetMapping("/offices")
    public PagerVO<OfficeListVO> list(
            @ApiParam(value = "事务所名称") @RequestParam(required = false) String name,
            @ApiParam(value = "类型:company公司，office事务所") @RequestParam(required = false) String type,
            @ApiParam(value = "有效期-开始时间(待确认)") @RequestParam(required = false) Date startTime,
            @ApiParam(value = "有效期-结束时间(待确认)") @RequestParam(required = false) Date endTime,
            @ApiParam(value = "当前页") @RequestParam(required = false, defaultValue = "1") int page,
            @ApiParam(value = "每页显示数量") @RequestParam(required = false, defaultValue = "10") int pageSize
    ) {
        return officeService.list(name, type, startTime, endTime, page, pageSize);
    }

    @ApiOperation(value = "事务所列表,用于下拉框选择《完》")
    @GetMapping("/offices/simple")
    public PagerVO<OfficeBaseVO> listSimple(
            @ApiParam(value = "关键字（事务所名称）") @RequestParam(required = false) String keys,
            @ApiParam(value = "类型:company公司，office事务所") @RequestParam(required = false) String type,
            @ApiParam(value = "当前页") @RequestParam(required = false, defaultValue = "1") int page,
            @ApiParam(value = "每页显示数量") @RequestParam(required = false, defaultValue = "10") int pageSize
    ) {
        return officeService.listSimple(keys, type, page, pageSize);
    }
}
